package xyz.iguilty.workflow.example.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.iguilty.workflow.example.entity.BusinessTrip;
import xyz.iguilty.workflow.example.service.BusinessTripService;

import java.text.SimpleDateFormat;
import java.util.*;

@RestController
@RequestMapping("/business-trip")
@Api(tags = "出差流程")
public class BusinessTripController {
    @Autowired
    private BusinessTripService businessTripService;
    @ApiOperation(value = "创建流程")
    @PostMapping(value = "/start")
    public String start(@RequestBody BusinessTrip businessTrip) {
        businessTripService.startProcess(businessTrip);
        return String.format("ok %s",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}
